package com.zzz.service.impl;

import com.aaa.entity.UAddr;
import com.aaa.security.util.WebUtils;
import com.aaa.util.JwtUtil;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzz.service.UAddrService;
import com.zzz.mapper.UAddrMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
* @author 86176
* @description 针对表【u_addr】的数据库操作Service实现
* @createDate 2023-03-09 19:12:52
*/
@Service
@SuppressWarnings("all")
public class UAddrServiceImpl extends ServiceImpl<UAddrMapper, UAddr>
    implements UAddrService{

    @Autowired
    private UAddrMapper uAddrMapper;

    //获取当前用户所有收获地址
    @Override
    public Result getAllAddr() {
        String token = WebUtils.getRequest().getHeader("token");
        Map<String, Object> tokenChaim = JwtUtil.getTokenChaim(token);
        Object username1 = tokenChaim.get("id");
        String username = username1.toString();
        List<UAddr> allAddr = uAddrMapper.getAllAddr(username);
        return new Result(2000,"查询成功",allAddr);
    }
}




